/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import dao.SanPhamKMDAO;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyVetoException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.Timer;
import net.sf.jasperreports.engine.JRException;
import pojo.ChuongTrinhKhuyenMai;
import pojo.CuaHang;
import pojo.NguoiDung;

/**
 *
 * @author LaiHuynh
 */
public class MainFrame extends javax.swing.JFrame {

    Timer thoigian;
    List<ChuongTrinhKhuyenMai> km = null;
    int bien = 0;
    int i = 0;
    int n = 0;
    /////
    private NguoiDung nguoiDung;

    public NguoiDung getNguoiDung() {
        return nguoiDung;
    }

    public void setNguoiDung(NguoiDung nguoiDung) {
        this.nguoiDung = nguoiDung;
    }

    /**
     * Creates new form MainFrame
     */
    public MainFrame() {
        initComponents();
        LayKM();
        n = km.size();
        thoigian = new Timer(3000, new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (bien == 0 && i < n) {
                    jlkhuyenmai.setText(String.valueOf(km.get(i).getSanPham().getTenSanPham()) + "   Khuyến mãi " + km.get(i).getKhuyenMai() + "% tại:  " + km.get(i).getSanPham().getCuaHang().getTenCuaHang());
                    bien = 1;
                    i++;
                } else if (bien == 1 && i < n) {
                    jlkhuyenmai.setText(String.valueOf(km.get(i).getSanPham().getTenSanPham()) + "   Khuyến mãi " + km.get(i).getKhuyenMai() + "% tại:  " + km.get(i).getSanPham().getCuaHang().getTenCuaHang());
                    bien = 0;
                    i++;
                } else {
                    jlkhuyenmai.setText("xin chao !!");
                    i = 0;
                    bien = 0;
                    LayKM();
                    n = km.size();

                }
            }
        });
        thoigian.start();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        DesktopPane = new javax.swing.JDesktopPane();
        jToolBar1 = new javax.swing.JToolBar();
        jlbThongTin = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jlkhuyenmai = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu3 = new javax.swing.JMenu();
        jmiDangNhap = new javax.swing.JMenuItem();
        jmiDangXuat = new javax.swing.JMenuItem();
        jmTiepNhan = new javax.swing.JMenu();
        jmiThemHangsx = new javax.swing.JMenuItem();
        jmiXoaCapNhatHangsx = new javax.swing.JMenuItem();
        jmiQuanLySanPham1 = new javax.swing.JMenuItem();
        kmiTimKiemSanPham1 = new javax.swing.JMenuItem();
        jmQuanLyPhieuNhapXuat = new javax.swing.JMenu();
        jmiPhieuNhapSanPham = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jmReport = new javax.swing.JMenu();
        miBaoCaoTon = new javax.swing.JMenuItem();
        miBaoCaoCongNo = new javax.swing.JMenuItem();
        jmiBaoCaoDoanhThuTheoCuaHang = new javax.swing.JMenuItem();
        miQuyDinh = new javax.swing.JMenuItem();
        miKhachHang = new javax.swing.JMenuItem();
        miCuaHang = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        jmQuanLy = new javax.swing.JMenu();
        jimQuanLyQuyDinh = new javax.swing.JMenuItem();
        jmiQuanLyKhachHang = new javax.swing.JMenuItem();
        jmiQuanLyCuaHang = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenuItem9 = new javax.swing.JMenuItem();

        jMenu1.setText("jMenu1");

        jMenu2.setText("jMenu2");

        jMenuItem3.setText("jMenuItem3");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("CHUONG TRINH QUAN LY CHUOI CUA HANG THIET BI KI THUAT SO");

        DesktopPane.setBackground(new java.awt.Color(255, 153, 0));
        getContentPane().add(DesktopPane, java.awt.BorderLayout.CENTER);

        jToolBar1.setRollover(true);
        jToolBar1.setPreferredSize(new java.awt.Dimension(20, 20));

        jlbThongTin.setText("Bạn chưa đăng nhập");
        jToolBar1.add(jlbThongTin);

        jLabel1.setBackground(new java.awt.Color(0, 204, 204));
        jLabel1.setText("        Thông Tin Khuyến Mãi");
        jLabel1.setMaximumSize(new java.awt.Dimension(205, 14));
        jToolBar1.add(jLabel1);

        jlkhuyenmai.setBackground(new java.awt.Color(51, 51, 255));
        jlkhuyenmai.setForeground(new java.awt.Color(255, 51, 51));
        jlkhuyenmai.setAlignmentX(25);
        jlkhuyenmai.setMaximumSize(new java.awt.Dimension(700, 14));
        jToolBar1.add(jlkhuyenmai);

        getContentPane().add(jToolBar1, java.awt.BorderLayout.PAGE_END);

        jMenu3.setText("Hệ Thống");

        jmiDangNhap.setText("Đăng Nhập");
        jmiDangNhap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiDangNhapActionPerformed(evt);
            }
        });
        jMenu3.add(jmiDangNhap);

        jmiDangXuat.setText("Đăng Xuất");
        jmiDangXuat.setEnabled(false);
        jmiDangXuat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiDangXuatActionPerformed(evt);
            }
        });
        jMenu3.add(jmiDangXuat);

        jMenuBar1.add(jMenu3);

        jmTiepNhan.setText("Tiếp Nhận - Tìm kiếm");
        jmTiepNhan.setEnabled(false);
        jmTiepNhan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmTiepNhanActionPerformed(evt);
            }
        });

        jmiThemHangsx.setText("Thêm Hãng Sản Xuất");
        jmiThemHangsx.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiThemHangsxActionPerformed(evt);
            }
        });
        jmTiepNhan.add(jmiThemHangsx);

        jmiXoaCapNhatHangsx.setText("Xóa Cập Nhật Hãng Sản Xuất");
        jmiXoaCapNhatHangsx.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiXoaCapNhatHangsxActionPerformed(evt);
            }
        });
        jmTiepNhan.add(jmiXoaCapNhatHangsx);

        jmiQuanLySanPham1.setText("Quản Lý Sản Phẩm");
        jmiQuanLySanPham1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiQuanLySanPham1ActionPerformed(evt);
            }
        });
        jmTiepNhan.add(jmiQuanLySanPham1);

        kmiTimKiemSanPham1.setText("Tìm Kiếm Sản Phẩm");
        kmiTimKiemSanPham1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                kmiTimKiemSanPham1ActionPerformed(evt);
            }
        });
        jmTiepNhan.add(kmiTimKiemSanPham1);

        jMenuBar1.add(jmTiepNhan);

        jmQuanLyPhieuNhapXuat.setForeground(new java.awt.Color(255, 0, 51));
        jmQuanLyPhieuNhapXuat.setText("Phiếu nhập - xuất");
        jmQuanLyPhieuNhapXuat.setEnabled(false);

        jmiPhieuNhapSanPham.setText("Phiếu Nhập Sản Phẩm");
        jmiPhieuNhapSanPham.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiPhieuNhapSanPhamActionPerformed(evt);
            }
        });
        jmQuanLyPhieuNhapXuat.add(jmiPhieuNhapSanPham);

        jMenuItem1.setText("Hóa Đơn Bán Hàng");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jmQuanLyPhieuNhapXuat.add(jMenuItem1);

        jMenuItem2.setText("Phiếu Thu Tiền");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jmQuanLyPhieuNhapXuat.add(jMenuItem2);

        jMenuBar1.add(jmQuanLyPhieuNhapXuat);

        jmReport.setForeground(new java.awt.Color(255, 0, 0));
        jmReport.setText("Thông kê");
        jmReport.setEnabled(false);

        miBaoCaoTon.setText("Báo Cáo Tồn");
        miBaoCaoTon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miBaoCaoTonActionPerformed(evt);
            }
        });
        jmReport.add(miBaoCaoTon);

        miBaoCaoCongNo.setText("Báo Cáo Công Nợ");
        miBaoCaoCongNo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miBaoCaoCongNoActionPerformed(evt);
            }
        });
        jmReport.add(miBaoCaoCongNo);

        jmiBaoCaoDoanhThuTheoCuaHang.setText("Báo Cáo Doanh Thu Theo Cửa Hàng");
        jmiBaoCaoDoanhThuTheoCuaHang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiBaoCaoDoanhThuTheoCuaHangActionPerformed(evt);
            }
        });
        jmReport.add(jmiBaoCaoDoanhThuTheoCuaHang);

        miQuyDinh.setText("Quy Định");
        miQuyDinh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miQuyDinhActionPerformed(evt);
            }
        });
        jmReport.add(miQuyDinh);

        miKhachHang.setText("Khách Hàng");
        miKhachHang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miKhachHangActionPerformed(evt);
            }
        });
        jmReport.add(miKhachHang);

        miCuaHang.setText("Cửa Hàng");
        miCuaHang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miCuaHangActionPerformed(evt);
            }
        });
        jmReport.add(miCuaHang);

        jMenuItem7.setText("Báo Cáo Sản Phẩm");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem7ActionPerformed(evt);
            }
        });
        jmReport.add(jMenuItem7);

        jMenuBar1.add(jmReport);

        jmQuanLy.setText("Quản lý");
        jmQuanLy.setEnabled(false);
        jmQuanLy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmQuanLyActionPerformed(evt);
            }
        });

        jimQuanLyQuyDinh.setText("Quản Lý Các Quy Định");
        jimQuanLyQuyDinh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jimQuanLyQuyDinhActionPerformed(evt);
            }
        });
        jmQuanLy.add(jimQuanLyQuyDinh);

        jmiQuanLyKhachHang.setText("Quản Lý Khách Hàng");
        jmiQuanLyKhachHang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiQuanLyKhachHangActionPerformed(evt);
            }
        });
        jmQuanLy.add(jmiQuanLyKhachHang);

        jmiQuanLyCuaHang.setText("Quản Lý Cửa Hàng");
        jmiQuanLyCuaHang.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiQuanLyCuaHangActionPerformed(evt);
            }
        });
        jmQuanLy.add(jmiQuanLyCuaHang);

        jMenuItem8.setText("Quản lý khuyến mãi");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jmQuanLy.add(jMenuItem8);

        jMenuItem9.setText("Quản lý nhân viên");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jmQuanLy.add(jMenuItem9);

        jMenuBar1.add(jmQuanLy);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents
    public void LayKM() {
        //List<ChuongTrinhKhuyenMai> ds=SanPhamKMDAO.LayKM();
        km = SanPhamKMDAO.LayKM();
        Date now = new Date(System.currentTimeMillis());
        try {
            for (int i = 0; i < km.size(); i++) {

                ChuongTrinhKhuyenMai ctkm = km.get(i);
                Date bd = ctkm.getNgayBatDau();
                Date kt = ctkm.getNgayKetThuc();
                if (bd.compareTo(now) >= 0 || kt.compareTo(now) <= 0) {
                    //km.add(ctkm );
                    km.remove(i);
                }
            }
        } catch (Exception ex) {
        }



    }
    private void jmTiepNhanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmTiepNhanActionPerformed
        // TODO add your handling code here:
        QuanLySanPham frm = new QuanLySanPham(this.nguoiDung);
        frm.setVisible(true);
        this.DesktopPane.add(frm);
    }//GEN-LAST:event_jmTiepNhanActionPerformed

    private void jmiThemHangsxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiThemHangsxActionPerformed
        // TODO add your handling code here:
        ThemHangSanXuat frm = new ThemHangSanXuat();
        frm.setVisible(true);
        this.DesktopPane.add(frm);
    }//GEN-LAST:event_jmiThemHangsxActionPerformed

    private void jmiXoaCapNhatHangsxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiXoaCapNhatHangsxActionPerformed
        // TODO add your handling code here:
        XoaCapNhatHangsx frm = new XoaCapNhatHangsx();
        frm.setVisible(true);
        this.DesktopPane.add(frm);
    }//GEN-LAST:event_jmiXoaCapNhatHangsxActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        HoaDonBanHang frm = new HoaDonBanHang();
        CuaHang ch = this.nguoiDung.getCuaHang();
        frm.setMaCuaHang(ch.getMaCuaHang());
        frm.setVisible(true);
        this.DesktopPane.add(frm);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jmiPhieuNhapSanPhamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiPhieuNhapSanPhamActionPerformed
        // TODO add your handling code here:
        PhieuNhapSanPham frm = new PhieuNhapSanPham();
        CuaHang ch = this.nguoiDung.getCuaHang();
        frm.setMaCuaHang(ch.getMaCuaHang());
        frm.setVisible(true);
        this.DesktopPane.add(frm);
    }//GEN-LAST:event_jmiPhieuNhapSanPhamActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
        PhieuThuTien frm = new PhieuThuTien();
        frm.setVisible(true);
        this.DesktopPane.add(frm);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void miBaoCaoTonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miBaoCaoTonActionPerformed
        // TODO add your handling code here:
        try {
            HashMap pm = new HashMap();
            SubReport myiReportViewer = new SubReport("src/report/rptBaoCaoTon.jasper", pm);
            myiReportViewer.setBounds(0, 0, this.DesktopPane.getWidth(), DesktopPane.getHeight());
            myiReportViewer.setVisible(true);
            DesktopPane.add(myiReportViewer);
            myiReportViewer.setSelected(true);
        } catch (JRException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (PropertyVetoException pve) {
            pve.printStackTrace();
        }
    }//GEN-LAST:event_miBaoCaoTonActionPerformed

    private void miBaoCaoCongNoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miBaoCaoCongNoActionPerformed
        // TODO add your handling code here:
        try {
            HashMap pm = new HashMap();
            SubReport myiReportViewer = new SubReport("src/report/rptBaoCaoCongNo.jasper", pm);
            myiReportViewer.setBounds(0, 0, this.DesktopPane.getWidth(), DesktopPane.getHeight());
            myiReportViewer.setVisible(true);
            DesktopPane.add(myiReportViewer);
            myiReportViewer.setSelected(true);
        } catch (JRException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        } catch (PropertyVetoException pve) {
            pve.printStackTrace();
        }
    }//GEN-LAST:event_miBaoCaoCongNoActionPerformed

    private void jmiBaoCaoDoanhThuTheoCuaHangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiBaoCaoDoanhThuTheoCuaHangActionPerformed
        // TODO add your handling code here:
        String input = JOptionPane.showInputDialog("Nhập mã cữa hàng:");
        if (input != null) {
            try {
                int salesNo = Integer.parseInt(input);
                HashMap pm = new HashMap();
                pm.put("maCuaHang", salesNo);
                SubReport myiReportViewer = new SubReport("src/report/rptBaoCaoDoanhThu.jasper", pm);
                myiReportViewer.setBounds(0, 0, this.DesktopPane.getWidth(), DesktopPane.getHeight());
                myiReportViewer.setVisible(true);
                DesktopPane.add(myiReportViewer);
                myiReportViewer.setSelected(true);
            } catch (JRException ex) {
                Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            } catch (PropertyVetoException pve) {
                pve.printStackTrace();
            }
        }
    }//GEN-LAST:event_jmiBaoCaoDoanhThuTheoCuaHangActionPerformed

    private void jmiDangNhapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiDangNhapActionPerformed
        DangNhap_Dialog frm = new DangNhap_Dialog(this, true);
        frm.setVisible(true);
        if (frm.isKetQuaDangNhap() == true) {
            this.jmiDangNhap.setEnabled(false);
            this.jmiDangXuat.setEnabled(true);
            this.jmQuanLyPhieuNhapXuat.setEnabled(true);
            this.jmReport.setEnabled(true);
            this.jmQuanLy.setEnabled(true);
            this.jmTiepNhan.setEnabled(true);
            this.nguoiDung = frm.getNguoiDung();
            this.jlbThongTin.setText("Xin chào: " + nguoiDung.getTenNguoiDung());
        }
    }//GEN-LAST:event_jmiDangNhapActionPerformed

    private void jmiDangXuatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiDangXuatActionPerformed
        this.jmiDangNhap.setEnabled(true);
        this.jmiDangXuat.setEnabled(false);
        this.jmQuanLyPhieuNhapXuat.setEnabled(false);
        this.jmQuanLy.setEnabled(false);
        this.jmTiepNhan.setEnabled(false);
        this.jmReport.setEnabled(false);

        //dong tat ca cac internal frame
        for (int i = 0; i < this.DesktopPane.getAllFrames().length; i++) {
            this.DesktopPane.getAllFrames()[i].setVisible(false);
        }
        this.jlbThongTin.setText("Bạn chưa đăng nhập");
    }//GEN-LAST:event_jmiDangXuatActionPerformed
    //phi-quan lú quy định
    private void jimQuanLyQuyDinhActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jimQuanLyQuyDinhActionPerformed
        ThemQuiDinh frm = new ThemQuiDinh();
        frm.setVisible(true);
        this.DesktopPane.add(frm);
    }//GEN-LAST:event_jimQuanLyQuyDinhActionPerformed

    private void jmiQuanLyKhachHangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiQuanLyKhachHangActionPerformed
        // TODO add your handling code here:
        QuanLyKhachHang frm = new QuanLyKhachHang();
        frm.setVisible(true);
        this.DesktopPane.add(frm);
    }//GEN-LAST:event_jmiQuanLyKhachHangActionPerformed

    private void jmQuanLyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmQuanLyActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jmQuanLyActionPerformed

    private void jmiQuanLyCuaHangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiQuanLyCuaHangActionPerformed
        // TODO add your handling code here:
        QuanLyCuaHang frm = new QuanLyCuaHang();
        frm.setVisible(true);
        this.DesktopPane.add(frm);
    }//GEN-LAST:event_jmiQuanLyCuaHangActionPerformed

    private void miQuyDinhActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miQuyDinhActionPerformed
        HashMap hm = new HashMap();
        SubReport myiReportViewer = null;
        try {
            myiReportViewer = new SubReport("src/report/report1.jasper", hm);
            myiReportViewer.setBounds(0, 0, DesktopPane.getWidth(), DesktopPane.getHeight());
            myiReportViewer.setVisible(true);
            DesktopPane.add(myiReportViewer);
        } catch (JRException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_miQuyDinhActionPerformed

    private void miKhachHangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miKhachHangActionPerformed
        HashMap hm = new HashMap();
        SubReport myiReportViewer = null;
        try {
            myiReportViewer = new SubReport("src/report/KhachHang.jasper", hm);
            myiReportViewer.setBounds(0, 0, DesktopPane.getWidth(), DesktopPane.getHeight());
            myiReportViewer.setVisible(true);
            DesktopPane.add(myiReportViewer);
        } catch (JRException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_miKhachHangActionPerformed

    private void miCuaHangActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miCuaHangActionPerformed
        HashMap hm = new HashMap();
        SubReport myiReportViewer = null;
        try {
            myiReportViewer = new SubReport("src/report/CuaHang.jasper", hm);
            myiReportViewer.setBounds(0, 0, DesktopPane.getWidth(), DesktopPane.getHeight());
            myiReportViewer.setVisible(true);
            DesktopPane.add(myiReportViewer);
        } catch (JRException ex) {
            Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_miCuaHangActionPerformed

    private void jMenuItem7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem7ActionPerformed
        // TODO add your handling code here:
        String input = JOptionPane.showInputDialog("Nhập mã cữa hàng:");
        if (input != null) {
            try {
                int salesNo = Integer.parseInt(input);
                HashMap pm = new HashMap();
                pm.put("mach", salesNo);
                SubReport myiReportViewer = new SubReport("src/report/QLSanPham.jasper", pm);
                myiReportViewer.setBounds(0, 0, this.DesktopPane.getWidth(), DesktopPane.getHeight());
                myiReportViewer.setVisible(true);
                DesktopPane.add(myiReportViewer);
                myiReportViewer.setSelected(true);
            } catch (JRException ex) {
                Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            } catch (PropertyVetoException pve) {
                pve.printStackTrace();
            }
        }
    }//GEN-LAST:event_jMenuItem7ActionPerformed

    private void jmiQuanLySanPham1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiQuanLySanPham1ActionPerformed
        // TODO add your handling code here:
        QuanLySanPham frm = new QuanLySanPham(this.nguoiDung);
        frm.setVisible(true);
        this.DesktopPane.add(frm);
    }//GEN-LAST:event_jmiQuanLySanPham1ActionPerformed

    private void kmiTimKiemSanPham1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kmiTimKiemSanPham1ActionPerformed
        // TODO add your handling code here:
        TimKiemSanPham frm = new TimKiemSanPham();
        frm.setVisible(true);
        this.DesktopPane.add(frm);
    }//GEN-LAST:event_kmiTimKiemSanPham1ActionPerformed

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        // TODO add your handling code here:
        QLKhuyenMai frm = new QLKhuyenMai();
        frm.setVisible(true);
        this.DesktopPane.add(frm);
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
        // TODO add your handling code here:
        QLNhanVien frm = new QLNhanVien(this.nguoiDung);
        frm.setVisible(true);
        this.DesktopPane.add(frm);
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane DesktopPane;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JMenuItem jimQuanLyQuyDinh;
    private javax.swing.JLabel jlbThongTin;
    private javax.swing.JLabel jlkhuyenmai;
    private javax.swing.JMenu jmQuanLy;
    private javax.swing.JMenu jmQuanLyPhieuNhapXuat;
    private javax.swing.JMenu jmReport;
    private javax.swing.JMenu jmTiepNhan;
    private javax.swing.JMenuItem jmiBaoCaoDoanhThuTheoCuaHang;
    private javax.swing.JMenuItem jmiDangNhap;
    private javax.swing.JMenuItem jmiDangXuat;
    private javax.swing.JMenuItem jmiPhieuNhapSanPham;
    private javax.swing.JMenuItem jmiQuanLyCuaHang;
    private javax.swing.JMenuItem jmiQuanLyKhachHang;
    private javax.swing.JMenuItem jmiQuanLySanPham1;
    private javax.swing.JMenuItem jmiThemHangsx;
    private javax.swing.JMenuItem jmiXoaCapNhatHangsx;
    private javax.swing.JMenuItem kmiTimKiemSanPham1;
    private javax.swing.JMenuItem miBaoCaoCongNo;
    private javax.swing.JMenuItem miBaoCaoTon;
    private javax.swing.JMenuItem miCuaHang;
    private javax.swing.JMenuItem miKhachHang;
    private javax.swing.JMenuItem miQuyDinh;
    // End of variables declaration//GEN-END:variables
}
